/* 
 * File         : question.h
 * Author       : anthony
 *
 * Created on February 1, 2012, 12:38 AM
 */
#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;

class Question
{
private:
    string topic, qns;
    int ans, count;
    vector <string> vQuestion;
    vector <string> vTopic;
    vector <int> vAns;
public:
    Question();
    void enterQuestion();
    void retrieveQuestion();
};

Question::Question()
{
    topic = "";
    qns = "";
    ans = 0;
    count = 0;
}

void Question::enterQuestion()
{
    ofstream ass02;
    ass02.open("assignment02_Qns.txt", fstream::app);
    while(count != 20)
    {
        cout << "Topic: ";
        cin.get();
        getline(cin, topic);
        vTopic.push_back(topic);
        
        cout << "Question: ";
        getline(cin, qns);
        vQuestion.push_back(qns);
        
        cout << "Answer: ";
        cin >> ans;
        vAns.push_back(ans);
        count ++;
    }
    for (int i = 0; i < vQuestion.size(); i++) 
    {
        cout << vTopic[i] << ":<Question" << i + 1 << ">:" << vQuestion[i] << ":<Answer" << i + 1 << ">:" << vAns[i] << endl;
        ass02 << vTopic[i] << ":<Question" << i + 1 << ">:" << vQuestion[i] << ":<Answer" << i + 1 << ">:" << vAns[i] << endl;
    }
    ass02.close();
}

void Question::retrieveQuestion()
{
    string test;
    ifstream file("assignment02_Qns.txt");
    if(file.is_open())
    {
        while(file.good())
        {
            string data;
            while(getline(file, data))
            {
                test += data +'\n';
            }
        }
        file.close();
        cout << test << endl;
    }
}
/* QUESTION_H */